<%-- 
    Document   : func__courier_bill_statechange
    Created on : 2018-5-27, 21:15:00
    Author     : Dannis
--%>

<%@page import="com.antexpress.common.Const"%>
<%@page import="com.antexpress.pojo.Employee"%>
<%@page import="com.antexpress.bean.Authentication"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Express -- Ant Express</title>
        <link rel="shortcut icon" href="static/img/ant-logo.png">
        <link href="static/css/style.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/normalize.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/default.css" rel="stylesheet" type="text/css"/>
        <link href="static/dist/css/jquery.secretnav.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/demo.css" rel="stylesheet" type="text/css"/>
        <link href="static/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/edbox.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/selectpage.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/stickysort.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <%
            if (!Authentication.isLogin(session)) {
                response.sendRedirect("index.jsp");
                return;
            }
            Employee emp = (Employee) session.getAttribute(Const.CURRENT_USER);
            if (!Authentication.isHRAdmin(emp) && !Authentication.isExpressAdmin(emp)
                    && !Authentication.isExpressCourier(emp) && !Authentication.isExpressAreaManager(emp)
                    && !Authentication.isExpressLogisticsApproval(emp) && !Authentication.isExpressLogisticsManager(emp)) {
                response.sendRedirect("404.jsp");
                return;
            }

        %>
        <div class="sn-outer-wrapper sn-moveleft modalview">
            <div class="sn-content-wrapper transform" style="cursor: default;">
                <div id="content" style="top: 0px;">
                    <jsp:include page="ui/header.jsp"/>
                    <div class="container-nav">
                        <div class="container">
                            <button class="open btn btn-default bt-open" title="Menu"><i class="fa fa-bars" aria-hidden="true"></i></button>
                            <!--此处可以扩展其他的功能-->
                            <%                                if (Authentication.isExpressLogisticsManager(emp)) {
                                    out.println("<a href='express_courier.jsp' class='content-nav-bt'>Courier Management</a>");
                                    out.println("<a href='express_area_manager.jsp' class='content-nav-bt'>Area Manager Management</a>");
                                    out.println("<a href='express_logistics_approval.jsp' class='content-nav-bt'>Logistics Approval Management</a>");
                                }
                            %>
                        </div>
                    </div>
                    <div class="container" style="text-align: left;color: #000">
                        <h1 class="heading"><i class="fa fa-book" aria-hidden="true"></i> Express Management</h1>
                        <div class="content-div">
                            <!--创建新的Bill表单-->
                            <div class="createbill" >
                                <h4 id="addnewbillSlider" class="createbill-title subheading"><i class="fa fa-chevron-right" aria-hidden="true"></i> Add New Bill<i class="fa fa-caret-down" aria-hidden="true"></i></h4>
                                <form id="addnewbillForm" onsubmit="return false;" style="display:none;">
                                    <div class="div-consignor">
                                        <h5 class="table-header" style="font-size: 12pt; color: #6855bb">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-chevron-right" aria-hidden="true"></i>Consignor Information</h5>
                                        <table class="table-create-consignor form-table">
                                            <tr>
                                                <td>Name</td>
                                                <td><input id="consignor-name" class="input-md-width" type="text" minlength="1" maxlength="50"/></td>
                                            </tr>
                                            <tr>
                                                <td>Phone</td>
                                                <td><input id="consignor-phone" class="input-md-width" type="number" minlength="1" maxlength="11"/></td>
                                            </tr>
                                            <tr>
                                                <td>Address</td>
                                                <td>
                                                    <br/>
                                                    <input type="text" id="selectPageProvince-consignor" placeholder="Province" style="width: 65px;"/>
                                                    <input type="text" id="selectPageCity-consignor" placeholder="City" style="width: 65px;"/>
                                                    <input type="text" id="selectPageDistrict-consignor" placeholder="District" style="width: 65px;"/>
                                                    <input type="text" id="selectPageCityTown-consignor" placeholder="Town" style="width: 65px;"/></td>
                                            </tr>
                                            <tr>
                                                <td style="vertical-align: top">Comment</td>
                                                <td><textarea id="address-moreinfo-consignor" class="area-md" maxlength="80"></textarea></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="div-consignee">
                                        <h5 class="table-header" style="font-size: 12pt; color: #6855bb">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-chevron-right" aria-hidden="true"></i>Consignee Information</h5>
                                        <table class="table-create-consignee form-table">
                                            <tr>
                                                <td>Name</td>
                                                <td><input id="consignee-name" class="input-md-width" type="text" minlength="1" maxlength="50"/></td>
                                            </tr>
                                            <tr>
                                                <td>Phone</td>
                                                <td><input id="consignee-phone" class="input-md-width" type="number" minlength="1" maxlength="11"/></td>
                                            </tr>
                                            <tr>
                                                <td>Address</td>
                                                <td><br/><input type="text" id="selectPageProvince-consignee" placeholder="Province" style="width: 65px;"/>
                                                    <input type="text" id="selectPageCity-consignee" placeholder="City" style="width: 65px;"/>
                                                    <input type="text" id="selectPageDistrict-consignee" placeholder="District" style="width: 65px;"/>
                                                    <input type="text" id="selectPageCityTown-consignee" placeholder="Town" style="width: 65px;"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="vertical-align: top">Comment</td>
                                                <td><textarea id="address-moreinfo-consignee" class="area-md" maxlength="80"></textarea></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="div-bill-info">
                                        <h5 class="table-header" style="font-size: 12pt; color: #6855bb">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-chevron-right" aria-hidden="true"></i>Bill Information</h5>
                                        <table class="table-create-bill-info form-table">
                                            <tr>                                         
                                                <td>Weight</td>
                                                <td><input id="billweight" class="input-md-width" type="number" min="0"/> KG</td>
                                            </tr>
                                            <tr>
                                                <td>Amount</td>
                                                <td><input id="billamount" class="input-md-width" type="number" min="0"/></td>
                                            </tr>
                                            <tr>
                                                <td>Freight</td>
                                                <td><input id="billfreight" class="input-md-width" type="number" min="0"/>￥</td>
                                            </tr>
                                            <tr>
                                                <td>Insurance</td>
                                                <td><input id="billInsurance" class="input-md-width" type="number" value="0" min="0"/></td>
                                            </tr>
                                            <tr>
                                                <td>PayWay</td>
                                                <td>
                                                    <input type="radio" name="payway-radio" checked="true" value="0">Online
                                                    <input type="radio" name="payway-radio" value="1">Cash on delivery
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="vertical-align: top;">Comment</td>
                                                <td><textarea id="bill-moreinfo-comment" class="area-md" maxlength="80"></textarea></td>
                                            </tr>
                                        </table>
                                    </div>
                                    <input type="button" class="btn btn-primary" style="margin-left: 50%" value="Submit" onclick="savebillinfo()"/>
                                </form>
                            </div><!--创建表单结束div-->

                            <!--查询本区域的业务单-->
                            <div class="div-normalbill-select content-div">
                                <form  onsubmit="return false;">
                                    <div class="div-search">
                                        <h4 id="serarchNormalbillSlider" class="createbill-title subheading"><i class="fa fa-chevron-right" aria-hidden="true"></i>Search Normal bill<i class="fa fa-caret-down" aria-hidden="true"></i></h4>
                                        <div id="serarchNormalbilldiv">
                                            <table style="width: 100%;margin-bottom: 5px;">
                                                <tr>
                                                    <td style="font-weight: 500">CRDT</td>
                                                    <td><input type="date" id="selectStartPageCreateTime" placeholder="Please select Time" style="width: 138px;"/></td>
                                                    <td>to</td>
                                                    <td><input type="date" id="selectEndPageCreateTime" placeholder="Please select Time" style="width: 138px;"/></td>
                                                    <td style="font-weight: 500">&nbsp;UPDT</td>
                                                    <td><input type="date" id="selectStartPageUpdateTime" placeholder="Please select Time" style="width: 138px;"/></td>
                                                    <td>to</td>
                                                    <td><input type="date" id="selectEndPageUpdateTime" placeholder="Please select Time" style="width: 138px;"/></td>
                                                    <td>
                                                        &nbsp;<button type="submit" class="btn btn-primary" onclick="searchNormalbill()"><i class="fa fa-search" aria-hidden="true"></i></button>
                                                        &nbsp;<button class="btn btn-default" title="Refresh" onclick="getNormalBillList();"><i class="fa fa-refresh" aria-hidden="true"></i></button>
                                                    </td>
                                                </tr>
                                            </table>
                                            <table id="search-table" class="pub-table pub-table-hover">
                                                <thead>
                                                    <tr>
                                                        <th>&nbsp;<i class="fa fa-check-square-o" aria-hidden="true"></i>&nbsp;</th>
                                                        <th>Consignor</th>
                                                        <th>City</th>
                                                        <th>Consignee</th>
                                                        <th>City</th>
                                                        <th>CreateTime</th>
                                                        <th>UpdateTime</th>
                                                        <th>&nbsp;<i class="fa fa-pencil-square-o" aria-hidden="true"></i>&nbsp;</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="bill-table-body">

                                                </tbody>
                                                <input type="hidden" id="search-emp-page" value="1"/>
                                            </table>
                                            <div id="searchResultMsg" class="content-center table-result-msg">

                                            </div>
                                            <!--详细信息模态框-->
                                            <div id="bill-show-box" class="ed-div" style="display:none;">
                                                <h3 class="subheading" style="margin: 3px;"><i class="fa fa-info-circle" aria-hidden="true"></i> Bill Details</h3><br/>
                                                <table class="model-form-table" style="color: black;">
                                                    <tr style="display: none">
                                                        <td>BillID</td>
                                                        <td id="bill-show-BillID"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>ConsignorName</td>
                                                        <td id="bill-show-ConsignorName"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>ConsignorCity</td>
                                                        <td id="bill-show-ConsignorCity"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>ConsigneeName</td>
                                                        <td id="bill-show-ConsigneeName"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>ConsigneeCity</td>
                                                        <td id="bill-show-ConsigneeCity"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Weight</td>
                                                        <td id="bill-show-Weight"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Amount</td>
                                                        <td id="bill-show-Amount"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Freight</td>
                                                        <td id="bill-show-Freight"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>PayWay</td>
                                                        <td id="bill-show-PayWay"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Insurance</td>
                                                        <td id="bill-show-Insurance"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>CreateTime</td>
                                                        <td id="bill-show-CreateTime"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>UpdateTime</td>
                                                        <td id="bill-show-UpdateTime"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Commits</td>
                                                        <td id="bill-show-Commits"></td>
                                                    </tr>
                                                </table>
                                                <input type="button" id="bt-add-emp-cancel" onclick="passbill()" class="btn btn-default" value="Pass"/>
                                                <input type="button" id="bt-add-emp-cancel" onclick="$.edbox('close');" class="btn btn-default" value="Close"/>
                                            </div><!-- 展示订单信息模态框 结束 -->

                                            <div class="content-center">
                                                <ul class="pagination" id="empPag"></ul>
                                            </div>

                                        </div>
                                    </div>
                                </form>
                            </div><!--查询本区域的业务单-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="sn-nav-wrapper">
                <nav id="nav" class="sn-nav left vertical">
                    <jsp:include page="ui/nav.jsp"/>
                </nav>
            </div>
        </div>
        <script src="static/js/modernizr.custom.25376.js" type="text/javascript"></script>
        <script src="static/js/jquery.js" type="text/javascript"></script>
        <script src="static/js/common-script.js" type="text/javascript"></script>
        <script src="static/dist/js/jquery.secretnav.js" type="text/javascript"></script>
        <script src="static/js/jquery.ba-throttle-debounce.min.js" type="text/javascript"></script>
        <script src="static/js/jquery.edbox.js" type="text/javascript"></script>
        <script src="static/js/selectpage.js" type="text/javascript"></script>
        <script src="static/js/jquery.stickysort.js" type="text/javascript"></script>
        <script src="static/js/jqPaginator.js" type="text/javascript"></script>
        <script>
                                                    var bill_select_data_province = {}; //获得省信息
                                                    var bill_select_data_city = {}; //获得市信息
                                                    var bill_select_data_district = {}; //获得区信息
                                                    var bill_select_data_town = {}; //获得镇信息
                                                    $(function () {
                                                        menu();
                                                        $("#search-table").stickySort();
                                                        initFunctionSlider();//无问题
                                                        buildEmpPag(1, 1);
                                                        initTown_select();
                                                        list_bills_selector_province();
                                                        init_city_select();
                                                        init_district_select();
                                                    });
                                                    //给需要从数据库查询的选择器进行异步获取数据，比喻获取省市信息
                                                    function list_bills_selector_province() {
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/list_working_bills_selector_province.do",
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    var resultdata = result.data;
                                                                    init_province_select(resultdata);
                                                                } else {

                                                                }
                                                            },
                                                            error: function () {

                                                            }
                                                        });
                                                    }
                                                    //省的选择器初始化
                                                    function init_province_select(prodata) {
                                                        $('#selectPageProvince-consignor').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: prodata, //给选择器赋值
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var proid = data.id;
                                                                    $.ajax({
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_city.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectprovince": proid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageCity-consignor').selectPageData(resultdata);
                                                                            } else {

                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageCity-consignor').selectPageClear();
                                                                $('#selectPageCity-consignor').selectPageData([]);
                                                                $('#selectPageDistrict-consignor').selectPageClear();
                                                                $('#selectPageDistrict-consignor').selectPageData([]);
                                                                $('#selectPageCityTown-consignor').selectPageClear();
                                                                $('#selectPageCityTown-consignor').selectPageData([]);
                                                            }
                                                        });

                                                        //初始End省份选择器初始化
                                                        $('#selectPageProvince-consignee').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: prodata,
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var proid = data.id;
                                                                    $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_city.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectprovince": proid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageCity-consignee').selectPageData(resultdata);
                                                                            } else {

                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageCity-consignee').selectPageClear();
                                                                $('#selectPageCity-consignee').selectPageData([]);
                                                                $('#selectPageDistrict-consignee').selectPageClear();
                                                                $('#selectPageDistrict-consignee').selectPageData([]);
                                                                $('#selectPageCityTown-consignee').selectPageClear();
                                                                $('#selectPageCityTown-consignee').selectPageData([]);
                                                            }
                                                        });
                                                    }

                                                    function init_city_select() {
                                                        $('#selectPageCity-consignor').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: [],
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var cityid = data.id;
                                                                    $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_district.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectcity": cityid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageDistrict-consignor').selectPageData(resultdata);
                                                                            } else {

                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageDistrict-consignor').selectPageClear();
                                                                $('#selectPageDistrict-consignor').selectPageData([]);
                                                                $('#selectPageCityTown-consignor').selectPageClear();
                                                                $('#selectPageCityTown-consignor').selectPageData([]);
                                                            }
                                                        });
                                                        $('#selectPageCity-consignee').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: [],
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var cityid = data.id;
                                                                    $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_district.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectcity": cityid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageDistrict-consignee').selectPageData(resultdata);
                                                                            } else {

                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageDistrict-consignee').selectPageClear();
                                                                $('#selectPageDistrict-consignee').selectPageData([]);
                                                                $('#selectPageCityTown-consignee').selectPageClear();
                                                                $('#selectPageCityTown-consignee').selectPageData([]);
                                                            }
                                                        });
                                                    }

                                                    function init_district_select() {
                                                        $('#selectPageDistrict-consignor').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: [],
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var districtid = data.id;
                                                                    $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_town.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectdistrict": districtid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageCityTown-consignor').selectPageData(resultdata);
                                                                            } else {
                                                                                alert(result.msg);
                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageCityTown-consignor').selectPageClear();
                                                                $('#selectPageCityTown-consignor').selectPageData([]);
                                                            }
                                                        });

                                                        $('#selectPageDistrict-consignee').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: [],
                                                            eSelect: function (data) {
                                                                if (data) {
                                                                    var districtid = data.id;
                                                                    $.ajax({//因为异步请求会再次开一个线程去获取，如果不嵌套的话赋值就附不上
                                                                        url: "${pageContext.request.contextPath}/express/list_working_bills_selector_town.do",
                                                                        type: "POST",
                                                                        dataType: "json",
                                                                        data: {
                                                                            "selectdistrict": districtid
                                                                        },
                                                                        success: function (result) {
                                                                            if (result.status === 1) {
                                                                                var resultdata = result.data;
                                                                                $('#selectPageCityTown-consignee').selectPageData(resultdata);
                                                                            } else {
                                                                                alert(result.msg);
                                                                            }
                                                                        },
                                                                        error: function () {

                                                                        }
                                                                    });
                                                                    //selectPageData()就是为组件加数据，这里的数据单元必须是一个完整的数据项
                                                                }
                                                            },
                                                            eClear: function () {//清空时，同时清空城市内容
                                                                $('#selectPageCityTown-consignee').selectPageClear();
                                                                $('#selectPageCityTown-consignee').selectPageData([]);
                                                            }
                                                        });

                                                    }
                                                    function initTown_select() {
                                                        $('#selectPageCityTown-consignor').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: []
                                                        });
                                                        $('#selectPageCityTown-consignee').selectPage({
                                                            showField: 'name',
                                                            keyField: 'id',
                                                            dropButton: false,
                                                            data: []
                                                        });
                                                    }

                                                    function savebillinfo() {
                                                        if ($("#billweight").val() === "") {
                                                            $.edbox({danger: "You need to input weight"});
                                                            return;
                                                        }
                                                        if ($("#billamount").val() === "") {
                                                            $.edbox({danger: "You need to input amount!!"});
                                                            return;
                                                        }
                                                        if ($("#billfreight").val() === "") {
                                                            $.edbox({danger: "You need to input freight!!"});
                                                            return;
                                                        }
                                                        if ($("input[name='payway-radio']").val() === "") {
                                                            $.edbox({danger: "You need to input payway!!"});
                                                            return;
                                                        }
                                                        if ($("#consignor-name").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor Name!!"});
                                                            return;
                                                        }
                                                        if ($("#consignor-phone").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor Phone!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageProvince-consignor").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor Province!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageCity-consignor").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor City!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageDistrict-consignor").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor Disttict!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageCityTown-consignor").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor Town!!"});
                                                            return;
                                                        }
                                                        if ($("#address-moreinfo-consignor").val() === "") {
                                                            $.edbox({danger: "You need to input Consignor AddressDetails!!"});
                                                            return;
                                                        }
                                                        if ($("#consignee-name").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee Name!!"});
                                                            return;
                                                        }
                                                        if ($("#consignee-phone").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee Phone!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageProvince-consignee").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee Province!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageCity-consignee").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee City!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageDistrict-consignee").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee District!!"});
                                                            return;
                                                        }
                                                        if ($("#selectPageCityTown-consignee").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee Town!!"});
                                                            return;
                                                        }
                                                        if ($("#address-moreinfo-consignee").val() === "") {
                                                            $.edbox({danger: "You need to input Consignee Address Details!!"});
                                                            return;
                                                        }
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/save_bill_info.do",
                                                            data: {
                                                                "weight": $("#billweight").val(),
                                                                "amount": $("#billamount").val(),
                                                                "freight": $("#billfreight").val(),
                                                                "payway": $("input[name='payway-radio']").val(),
                                                                "insurance": $("#billInsurance").val(),
                                                                "comment": $("#bill-moreinfo-comment").val(),
                                                                "consignorname": $("#consignor-name").val(),
                                                                "consignorphone": $("#consignor-phone").val(),
                                                                "consignorprovinceid": $("#selectPageProvince-consignor").val(),
                                                                "consignorcityid": $("#selectPageCity-consignor").val(),
                                                                "consignordistrictid": $("#selectPageDistrict-consignor").val(),
                                                                "consignortownid": $("#selectPageCityTown-consignor").val(),
                                                                "consignordressDetails": $("#address-moreinfo-consignor").val(),
                                                                "consigneename": $("#consignee-name").val(),
                                                                "consigneephone": $("#consignee-phone").val(),
                                                                "consigneeprovinceid": $("#selectPageProvince-consignee").val(),
                                                                "consigneecityid": $("#selectPageCity-consignee").val(),
                                                                "consigneedistrictid": $("#selectPageDistrict-consignee").val(),
                                                                "consigneetownid": $("#selectPageCityTown-consignee").val(),
                                                                "consigneedressDetails": $("#address-moreinfo-consignee").val(),
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    $.edbox({success: "Saved success!"});
                                                                    clearNewBill();
                                                                } else {
                                                                    $.edbox({danger: result.msg});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: 'Save failed!'});
                                                            }
                                                        });
                                                    }
                                                    function clearNewBill() {
                                                        if ($("#addnewbillForm").css("display") !== "none")
                                                                $("#addnewbillForm").slideUp();
                                                                $("#billweight").val() = "";
                                                                $("#billamount").val() = "";
                                                                $("#billfreight").val() = "";
                                                                $("input[name='payway-radio']").val() = 0;
                                                                $("#billInsurance").val() = "";
                                                                $("#bill-moreinfo-comment").val() = "";
                                                                $("#consignor-name").val() = "";
                                                                $("#consignor-phone").val() = "";
                                                                $("#selectPageProvince-consignor").val() = "";
                                                                $("#selectPageCity-consignor").val() = "";
                                                                $("#selectPageDistrict-consignor").val() = "";
                                                                $("#selectPageCityTown-consignor").val() = "";
                                                                $("#address-moreinfo-consignor").val() = "";
                                                                $("#consignee-name").val() = "";
                                                                $("#consignee-phone").val() = "";
                                                                $("#selectPageProvince-consignee").val() = "";
                                                                $("#selectPageCity-consignee").val() = "";
                                                                $("#selectPageDistrict-consignee").val() = "";
                                                                $("#selectPageCityTown-consignee").val() = "";
                                                                $("#address-moreinfo-consignee").val() = "";
                                                    }


                                                    function initFunctionSlider() {
                                                        $("#addnewbillSlider").click(function () {
                                                            if ($("#addnewbillForm").css("display") !== "none")
                                                                $("#addnewbillForm").slideUp();
                                                            else {
                                                                $("#addnewbillForm").slideDown();
                                                            }
                                                        });
                                                        $("#serarchworkbillSlider").click(function () {
                                                            if ($("#serarchworkbillForm").css("display") !== "none")
                                                                $("#serarchworkbillForm").slideUp();
                                                            else {
                                                                $("#serarchworkbillForm").slideDown();
                                                            }
                                                        });
                                                        $("#serarchNormalbillSlider").click(function () {
                                                            if ($("#serarchNormalbilldiv").css("display") !== "none")
                                                                $("#serarchNormalbilldiv").slideUp();
                                                            else {
                                                                $("#serarchNormalbilldiv").slideDown();
                                                            }
                                                        });
                                                    }
                                                    ;
                                                    //获取相应区域的业务单信息
                                                    function getNormalBill() {
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/getNormalBill_info.do",
                                                            data: {
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {


                                                                } else {
                                                                    $.edbox({danger: result.msg});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: 'Save failed!'});
                                                            }
                                                        });
                                                    }

                                                    //获取业务单的列表信息
                                                    function getNormalBillList() {
                                                        $("#searchResultMsg").empty();
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/list_bills_status1.do",
                                                            data: {
                                                                "pageNo": $("#search-emp-page").val()
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    var billList = result.data.list;
                                                                    if (billList.length === 0) {
                                                                        $("#searchResultMsg").append("No Record!!");
                                                                    } else {
                                                                         buildNormalBillTable(billList);
                                                                        var totalPages = 1;
                                                                        if (result.data.totalPages !== 0)
                                                                            totalPages = result.data.totalPages;
                                                                        $('#empPag').jqPaginator('option', {
                                                                            totalPages: totalPages,
                                                                            currentPage: result.data.pageNo
                                                                        });
                                                                    }
                                                                } else {
                                                                    $.edbox({info: "Nothing Bills Now!"});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: "Nothing Bills Now!"});
                                                            }
                                                        });
                                                    }
                                                    function buildNormalBillTable(billList) {
                                                        $("#bill-table-body").empty();
                                                        var rowNum = 0;
                                                        if (billList != null) {
                                                            $.each(billList, function () {
                                                                rowNum++;
                                                                var billCheckbox = $("<td>").append("<input type='checkbox'/>");
                                                                var consignor = $("<td>").append(this.consignorInfo.name);
                                                                var consignor_city = $("<td>").append(this.consignorInfo.mapTown.mapDistrict.mapCity.name);
                                                                var consignee = $("<td>").append(this.consigneeInfo.name);
                                                                var consignee_city = $("<td>").append(this.consigneeInfo.mapTown.mapDistrict.mapCity.name);
                                                                var billcreatetime = $("<td>").append(new Date(this.createtime).toString().substring(-1, 15));
                                                                var billupdatetime = $("<td>").append(new Date(this.updatetime).toString().substring(-1, 15));
                                                                var showBillOp = $("<a href='#' title='Details' edbox data-box-target='#bill-show-box' billID='" + this.id + "' consignorname='" + this.consignorInfo.name + "' consignorcity='" + this.consignorInfo.mapTown.mapDistrict.mapCity.name
                                                                        + "' consigneename='" + this.consigneeInfo.name + "' consigneecity='" + this.consigneeInfo.mapTown.mapDistrict.mapCity.name + "' freight='" + this.freight + "' insured='" + this.insured + "' payway='" + this.panment
                                                                        + "' weight='" + this.weight + "' commit='" + this.commit + "' amount='" + this.amount + "' billcreatetime='" + this.createtime + "' billupdatetime='" + this.updatetime + "'></a>")
                                                                        .append("<i class='fa fa-pencil-square-o' aria-hidden='true'></i>");
                                                                showBillOp.click(function () {

                                                                    $("#bill-show-BillID").empty();
                                                                    $("#bill-show-BillID").append(showBillOp.attr("billID"));
                                                                    $("#bill-show-ConsignorName").empty();
                                                                    $("#bill-show-ConsignorName").append(showBillOp.attr("consignorname"));
                                                                    $("#bill-show-ConsignorCity").empty();
                                                                    $("#bill-show-ConsignorCity").append(showBillOp.attr("consignorcity"));
                                                                    $("#bill-show-ConsigneeName").empty();
                                                                    $("#bill-show-ConsigneeName").append(showBillOp.attr("consigneename"));
                                                                    $("#bill-show-ConsigneeCity").empty();
                                                                    $("#bill-show-ConsigneeCity").append(showBillOp.attr("consigneecity"));
                                                                    $("#bill-show-Weight").empty();
                                                                    $("#bill-show-Weight").append(showBillOp.attr("weight")).append("KG");
                                                                    $("#bill-show-Amount").empty();
                                                                    $("#bill-show-Amount").append(showBillOp.attr("amount"));
                                                                    $("#bill-show-Freight").empty();
                                                                    $("#bill-show-Freight").append(showBillOp.attr("freight")).append("$");
                                                                    $("#bill-show-PayWay").empty();
                                                                    if (showBillOp.attr("payway") === "0")
                                                                        $("#bill-show-PayWay").append("Online");
                                                                    else {
                                                                        $("#bill-show-PayWay").append("Pay On Delivery");
                                                                    }
                                                                    $("#bill-show-Insurance").empty();
                                                                    $("#bill-show-Insurance").append(showBillOp.attr("insured"));
                                                                    $("#bill-show-CreateTime").empty();
                                                                    $("#bill-show-CreateTime").append(timestampToDatetime(showBillOp.attr("billcreatetime")));
                                                                    $("#bill-show-UpdateTime").empty();
                                                                    $("#bill-show-UpdateTime").append(timestampToDatetime(showBillOp.attr("billupdatetime")));
                                                                    $("#bill-show-Commits").empty();
                                                                    $("#bill-show-Commits").append(showBillOp.attr("commit"));
                                                                });
                                                                showBillOp.edbox();
                                                                var billOp = $("<td>").append(showBillOp).append("&nbsp;&nbsp;&nbsp;");
//                                            列表身体赋值
                                                                var billRow = $("<tr>").append(billCheckbox).append(consignor)
                                                                        .append(consignor_city).append(consignee).append(consignee_city).append(billcreatetime).append(billupdatetime).append(billOp);
                                                                if (rowNum % 2 === 0)
                                                                    billRow.addClass("td-bk");
                                                                $("#bill-table-body").append(billRow);
                                                            });
                                                        }
                                                        $.edbox("Don't have any Bill");
                                                    }
                                                    //审批业务单
                                                    function passbill() {
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/passStatus1bill.do",
                                                            data: {
                                                                "billinfoID": $("#bill-show-BillID").text()
                                                                        //向后端传值的时候，如果是input就是value，如果是别的组件里的值，一般用text
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    alert("Changed Successful!!");
                                                                    $.edbox({success: result.msg});
                                                                    $.edbox('close');
                                                                    getNormalBillList();

                                                                } else {
                                                                    $.edbox({danger: result.msg});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: "Got failed!"});
                                                            }
                                                        });
                                                    }
                                                    //初始化获取billlist
                                                    function initlistofbill() {
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/list_bills_status1.do",
                                                            data: {
                                                                "pageNo": 1
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    var billList = result.data.list;
                                                                    buildNormalBillTable(billList);
                                                                    var totalPages = 1;
                                                                    if (result.data.totalPages !== 0)
                                                                        totalPages = result.data.totalPages;
                                                                    $('#empPag').jqPaginator('option', {
                                                                        totalPages: totalPages,
                                                                        currentPage: result.data.pageNo
                                                                    });
                                                                } else {
                                                                    $.edbox({info: result.msg});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: "Got failed!"});
                                                            }
                                                        });
                                                    }

                                                    function searchNormalbill() {
                                                        if ($("#selectStartPageCreateTime").val() === "") {
                                                            $.edbox({danger: "You need to enter one Start CreateTime!!"});
                                                            return;
                                                        }
                                                        if ($("#selectEndPageCreateTime").val() === "") {
                                                            $.edbox({danger: "You need to enter one End CreateTime!!"});
                                                            return;
                                                        }
                                                        if ($("#selectStartPageUpdateTime").val() === "") {
                                                            $.edbox({danger: "You need to enter one Start UpdateTime!!"});
                                                            return;
                                                        }
                                                        if ($("#selectEndPageUpdateTime").val() === "") {
                                                            $.edbox({danger: "You need to enter one End UpdateTime!!"});
                                                            return;
                                                        }
                                                        $("#search-emp-page").val("1");
                                                        $.ajax({
                                                            url: "${pageContext.request.contextPath}/express/searchNormalBills.do",
                                                            data: {
                                                                "createtimestart": $("#selectStartPageCreateTime").val(),
                                                                "createtimeend": $("#selectEndPageCreateTime").val(),
                                                                "updatetimestart": $("#selectStartPageUpdateTime").val(),
                                                                "updatetimeend": $("#selectEndPageUpdateTime").val()
                                                            },
                                                            type: "POST",
                                                            dataType: "json",
                                                            success: function (result) {
                                                                if (result.status === 1) {
                                                                    var billList = result.data.list;
                                                                    buildNormalBillTable(billList);
                                                                } else {
                                                                    $.edbox({info: result.msg});
                                                                }
                                                            },
                                                            error: function () {
//                                                                    $.edbox({danger: "Got failed!"});
                                                            }
                                                        });
                                                    }

                                                    function buildEmpPag(totalPages, currentPage) {
                                                        $('#empPag').jqPaginator({
                                                            totalPages: totalPages,
                                                            visiblePages: 5,
                                                            currentPage: currentPage,
                                                            first: '<li class="first"><a href="javascript:void(0);">First</a></li>',
                                                            prev: '<li class="prev"><a href="javascript:void(0);">Previous</a></li>',
                                                            next: '<li class="next"><a href="javascript:void(0);">Next</a></li>',
                                                            last: '<li class="last"><a href="javascript:void(0);">Last</a></li>',
                                                            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
                                                            onPageChange: function (num) {
                                                                $("#search-emp-page").val(num);
                                                                getNormalBillList();
                                                            }
                                                        });
                                                    }

        </script>
    </body>
</html>